package com.zyl.edthresholdtraining.controller;

import com.zyl.edthresholdtraining.common.AppConstant;
import com.zyl.edthresholdtraining.dto.UserTestDTO;
import com.zyl.edthresholdtraining.entity.UserTestResult;
import com.zyl.edthresholdtraining.mapper.UserResponseMapper;
import com.zyl.edthresholdtraining.service.UserResponseService;
import com.zyl.edthresholdtraining.vo.BaseException;
import com.zyl.edthresholdtraining.vo.RichResult;
import com.zyl.edthresholdtraining.vo.UserTestVO;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author zhangyulu
 * @description
 * @date 2020/7/31/031
 */
@Controller
@RequestMapping(AppConstant.PROJECT_NAME+"/userResponse")
public class UserResponseController {

    @Autowired
    private UserResponseService userResponseService;

    /*@ResponseBody
    @PostMapping("/check")
    @ApiOperation("检查用户输入是否正确")
    public RichResult check(@RequestBody UserTestDTO userTestDTO, HttpServletRequest request) throws BaseException {
        return new RichResult(userResponseService.check(userTestDTO, request));
    }*/

    @ResponseBody
    @PostMapping("/saveTestTimeAndResult")
    @ApiOperation(value = "保存被试的测试图片用时和被试的测试结果")
    public RichResult saveTestTime(HttpServletRequest req, String[] timeList, String[] answerList,Integer type, Long userId, Model model) throws BaseException, IOException {
        //返回被试测试结果数据
        return new RichResult(userResponseService.saveResult(req, timeList, answerList, type,userId));
    }

}
